﻿using System;
using System.Net;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;

namespace PickGold
{
	/// <summary>
	/// 位元
	/// </summary>
	public class BitUtil
	{
		#region Data - True

		/// <summary>
		/// -1
		/// </summary>
		public const long B64_TRUE = -1;

		/// <summary>
		/// -1
		/// </summary>
		public const int B32_TRUE = -1;

		/// <summary>
		/// -1
		/// </summary>
		public const short B16_TRUE = -1;

		/// <summary>
		/// -1
		/// </summary>
		public const sbyte BS8_TRUE = -1;

		#endregion

		#region Data - False

		/// <summary>
		/// 0
		/// </summary>
		public const long B64_FALSE = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const int B32_FALSE = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const short B16_FALSE = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const sbyte BS8_FALSE = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const byte B08_FALSE = 0;

		#endregion

		#region Data - Zero

		/// <summary>
		/// 0
		/// </summary>
		public const long B64_ZERO = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const int B32_ZERO = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const short B16_ZERO = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const sbyte BS8_ZERO = 0;

		/// <summary>
		/// 0
		/// </summary>
		public const byte B08_ZERO = 0;

		#endregion

		#region B64

		/// <summary>
		/// 0x0000000000000001 = 1
		/// </summary>
		public const long B64_00 = 0x0000000000000001;
		/// <summary>
		/// 0x0000000000000001 = 1
		/// </summary>
		public const long F64_00 = 0x0000000000000001;

		/// <summary>
		/// 0x0000000000000002 = 2
		/// </summary>
		public const long B64_01 = 0x0000000000000002;
		/// <summary>
		/// 0x0000000000000003 = 3
		/// </summary>
		public const long F64_01 = 0x0000000000000003;

		/// <summary>
		/// 0x0000000000000004 = 4
		/// </summary>
		public const long B64_02 = 0x0000000000000004;
		/// <summary>
		/// 0x0000000000000007 = 7
		/// </summary>
		public const long F64_02 = 0x0000000000000007;

		/// <summary>
		/// 0x0000000000000008 = 8
		/// </summary>
		public const long B64_03 = 0x0000000000000008;
		/// <summary>
		/// 0x000000000000000F = 15
		/// </summary>
		public const long F64_03 = 0x000000000000000F;

		/// <summary>
		/// 0x0000000000000010 = 16
		/// </summary>
		public const long B64_04 = 0x0000000000000010;
		/// <summary>
		/// 0x000000000000001F = 31
		/// </summary>
		public const long F64_04 = 0x000000000000001F;

		/// <summary>
		/// 0x0000000000000020 = 32
		/// </summary>
		public const long B64_05 = 0x0000000000000020;
		/// <summary>
		/// 0x000000000000003F = 63
		/// </summary>
		public const long F64_05 = 0x000000000000003F;

		/// <summary>
		/// 0x0000000000000040 = 64
		/// </summary>
		public const long B64_06 = 0x0000000000000040;
		/// <summary>
		/// 0x000000000000007F = 127
		/// </summary>
		public const long F64_06 = 0x000000000000007F;

		/// <summary>
		/// 0x0000000000000080 = 128
		/// </summary>
		public const long B64_07 = 0x0000000000000080;
		/// <summary>
		/// 0x00000000000000FF = 255
		/// </summary>
		public const long F64_07 = 0x00000000000000FF;

		/// <summary>
		/// 0x0000000000000100 = 256
		/// </summary>
		public const long B64_08 = 0x0000000000000100;
		/// <summary>
		/// 0x00000000000001FF = 511
		/// </summary>
		public const long F64_08 = 0x00000000000001FF;

		/// <summary>
		/// 0x0000000000000200 = 512
		/// </summary>
		public const long B64_09 = 0x0000000000000200;
		/// <summary>
		/// 0x00000000000003FF = 1023
		/// </summary>
		public const long F64_09 = 0x00000000000003FF;

		/// <summary>
		/// 0x0000000000000400 = 1024
		/// </summary>
		public const long B64_10 = 0x0000000000000400;
		/// <summary>
		/// 0x00000000000007FF = 2047
		/// </summary>
		public const long F64_10 = 0x00000000000007FF;

		/// <summary>
		/// 0x0000000000000800 = 2048
		/// </summary>
		public const long B64_11 = 0x0000000000000800;
		/// <summary>
		/// 0x0000000000000FFF = 4095
		/// </summary>
		public const long F64_11 = 0x0000000000000FFF;

		/// <summary>
		/// 0x0000000000001000 = 4096
		/// </summary>
		public const long B64_12 = 0x0000000000001000;
		/// <summary>
		/// 0x0000000000001FFF = 8191
		/// </summary>
		public const long F64_12 = 0x0000000000001FFF;

		/// <summary>
		/// 0x0000000000002000 = 8192
		/// </summary>
		public const long B64_13 = 0x0000000000002000;
		/// <summary>
		/// 0x0000000000003FFF = 16383
		/// </summary>
		public const long F64_13 = 0x0000000000003FFF;

		/// <summary>
		/// 0x0000000000004000 = 16384
		/// </summary>
		public const long B64_14 = 0x0000000000004000;
		/// <summary>
		/// 0x0000000000007FFF = 32767
		/// </summary>
		public const long F64_14 = 0x0000000000007FFF;

		/// <summary>
		/// 0x0000000000008000 = 32768
		/// </summary>
		public const long B64_15 = 0x0000000000008000;
		/// <summary>
		/// 0x000000000000FFFF = 65535
		/// </summary>
		public const long F64_15 = 0x000000000000FFFF;

		/// <summary>
		/// 0x0000000000010000 = 65536
		/// </summary>
		public const long B64_16 = 0x0000000000010000;
		/// <summary>
		/// 0x000000000001FFFF = 131071
		/// </summary>
		public const long F64_16 = 0x000000000001FFFF;

		/// <summary>
		/// 0x0000000000020000 = 131072
		/// </summary>
		public const long B64_17 = 0x0000000000020000;
		/// <summary>
		/// 0x000000000003FFFF = 262143
		/// </summary>
		public const long F64_17 = 0x000000000003FFFF;

		/// <summary>
		/// 0x0000000000040000 = 262144
		/// </summary>
		public const long B64_18 = 0x0000000000040000;
		/// <summary>
		/// 0x000000000007FFFF = 524287
		/// </summary>
		public const long F64_18 = 0x000000000007FFFF;

		/// <summary>
		/// 0x0000000000080000 = 524288
		/// </summary>
		public const long B64_19 = 0x0000000000080000;
		/// <summary>
		/// 0x00000000000FFFFF = 1048575
		/// </summary>
		public const long F64_19 = 0x00000000000FFFFF;

		/// <summary>
		/// 0x0000000000100000 = 1048576
		/// </summary>
		public const long B64_20 = 0x0000000000100000;
		/// <summary>
		/// 0x00000000001FFFFF = 2097151
		/// </summary>
		public const long F64_20 = 0x00000000001FFFFF;

		/// <summary>
		/// 0x0000000000200000 = 2097152
		/// </summary>
		public const long B64_21 = 0x0000000000200000;
		/// <summary>
		/// 0x00000000003FFFFF = 4194303
		/// </summary>
		public const long F64_21 = 0x00000000003FFFFF;

		/// <summary>
		/// 0x0000000000400000 = 4194304
		/// </summary>
		public const long B64_22 = 0x0000000000400000;
		/// <summary>
		/// 0x00000000007FFFFF = 8388607
		/// </summary>
		public const long F64_22 = 0x00000000007FFFFF;

		/// <summary>
		/// 0x0000000000800000 = 8388608
		/// </summary>
		public const long B64_23 = 0x0000000000800000;
		/// <summary>
		/// 0x0000000000FFFFFF = 16777215
		/// </summary>
		public const long F64_23 = 0x0000000000FFFFFF;

		/// <summary>
		/// 0x0000000001000000 = 16777216
		/// </summary>
		public const long B64_24 = 0x0000000001000000;
		/// <summary>
		/// 0x0000000001FFFFFF = 33554431
		/// </summary>
		public const long F64_24 = 0x0000000001FFFFFF;

		/// <summary>
		/// 0x0000000002000000 = 33554432
		/// </summary>
		public const long B64_25 = 0x0000000002000000;
		/// <summary>
		/// 0x0000000003FFFFFF = 67108863
		/// </summary>
		public const long F64_25 = 0x0000000003FFFFFF;

		/// <summary>
		/// 0x0000000004000000 = 67108864
		/// </summary>
		public const long B64_26 = 0x0000000004000000;
		/// <summary>
		/// 0x0000000007FFFFFF = 134217727
		/// </summary>
		public const long F64_26 = 0x0000000007FFFFFF;

		/// <summary>
		/// 0x0000000008000000 = 134217728
		/// </summary>
		public const long B64_27 = 0x0000000008000000;
		/// <summary>
		/// 0x000000000FFFFFFF = 268435455
		/// </summary>
		public const long F64_27 = 0x000000000FFFFFFF;

		/// <summary>
		/// 0x0000000010000000 = 268435456
		/// </summary>
		public const long B64_28 = 0x0000000010000000;
		/// <summary>
		/// 0x000000001FFFFFFF = 536870911
		/// </summary>
		public const long F64_28 = 0x000000001FFFFFFF;

		/// <summary>
		/// 0x0000000020000000 = 536870912
		/// </summary>
		public const long B64_29 = 0x0000000020000000;
		/// <summary>
		/// 0x000000003FFFFFFF = 1073741823
		/// </summary>
		public const long F64_29 = 0x000000003FFFFFFF;

		/// <summary>
		/// 0x0000000040000000 = 1073741824
		/// </summary>
		public const long B64_30 = 0x0000000040000000;
		/// <summary>
		/// 0x000000007FFFFFFF = 2147483647
		/// </summary>
		public const long F64_30 = 0x000000007FFFFFFF;

		/// <summary>
		/// 0x0000000080000000 = 2147483648
		/// </summary>
		public const long B64_31 = 0x0000000080000000;
		/// <summary>
		/// 0x00000000FFFFFFFF = 4294967295
		/// </summary>
		public const long F64_31 = 0x00000000FFFFFFFF;

		/// <summary>
		/// 0x0000000100000000 = 4294967296
		/// </summary>
		public const long B64_32 = 0x0000000100000000;
		/// <summary>
		/// 0x00000001FFFFFFFF = 8589934591
		/// </summary>
		public const long F64_32 = 0x00000001FFFFFFFF;

		/// <summary>
		/// 0x0000000200000000 = 8589934592
		/// </summary>
		public const long B64_33 = 0x0000000200000000;
		/// <summary>
		/// 0x00000003FFFFFFFF = 17179869183
		/// </summary>
		public const long F64_33 = 0x00000003FFFFFFFF;

		/// <summary>
		/// 0x0000000400000000 = 17179869184
		/// </summary>
		public const long B64_34 = 0x0000000400000000;
		/// <summary>
		/// 0x00000007FFFFFFFF = 34359738367
		/// </summary>
		public const long F64_34 = 0x00000007FFFFFFFF;

		/// <summary>
		/// 0x0000000800000000 = 34359738368
		/// </summary>
		public const long B64_35 = 0x0000000800000000;
		/// <summary>
		/// 0x0000000FFFFFFFFF = 68719476735
		/// </summary>
		public const long F64_35 = 0x0000000FFFFFFFFF;

		/// <summary>
		/// 0x0000001000000000 = 68719476736
		/// </summary>
		public const long B64_36 = 0x0000001000000000;
		/// <summary>
		/// 0x0000001FFFFFFFFF = 137438953471
		/// </summary>
		public const long F64_36 = 0x0000001FFFFFFFFF;

		/// <summary>
		/// 0x0000002000000000 = 137438953472
		/// </summary>
		public const long B64_37 = 0x0000002000000000;
		/// <summary>
		/// 0x0000003FFFFFFFFF = 274877906943
		/// </summary>
		public const long F64_37 = 0x0000003FFFFFFFFF;

		/// <summary>
		/// 0x0000004000000000 = 274877906944
		/// </summary>
		public const long B64_38 = 0x0000004000000000;
		/// <summary>
		/// 0x0000007FFFFFFFFF = 549755813887
		/// </summary>
		public const long F64_38 = 0x0000007FFFFFFFFF;

		/// <summary>
		/// 0x0000008000000000 = 549755813888
		/// </summary>
		public const long B64_39 = 0x0000008000000000;
		/// <summary>
		/// 0x000000FFFFFFFFFF = 1099511627775
		/// </summary>
		public const long F64_39 = 0x000000FFFFFFFFFF;

		/// <summary>
		/// 0x0000010000000000 = 1099511627776
		/// </summary>
		public const long B64_40 = 0x0000010000000000;
		/// <summary>
		/// 0x000001FFFFFFFFFF = 2199023255551
		/// </summary>
		public const long F64_40 = 0x000001FFFFFFFFFF;

		/// <summary>
		/// 0x0000020000000000 = 2199023255552
		/// </summary>
		public const long B64_41 = 0x0000020000000000;
		/// <summary>
		/// 0x000003FFFFFFFFFF = 4398046511103
		/// </summary>
		public const long F64_41 = 0x000003FFFFFFFFFF;

		/// <summary>
		/// 0x0000040000000000 = 4398046511104
		/// </summary>
		public const long B64_42 = 0x0000040000000000;
		/// <summary>
		/// 0x000007FFFFFFFFFF = 8796093022207
		/// </summary>
		public const long F64_42 = 0x000007FFFFFFFFFF;

		/// <summary>
		/// 0x0000080000000000 = 8796093022208
		/// </summary>
		public const long B64_43 = 0x0000080000000000;
		/// <summary>
		/// 0x00000FFFFFFFFFFF = 17592186044415
		/// </summary>
		public const long F64_43 = 0x00000FFFFFFFFFFF;

		/// <summary>
		/// 0x0000100000000000 = 17592186044416
		/// </summary>
		public const long B64_44 = 0x0000100000000000;
		/// <summary>
		/// 0x00001FFFFFFFFFFF = 35184372088831
		/// </summary>
		public const long F64_44 = 0x00001FFFFFFFFFFF;

		/// <summary>
		/// 0x0000200000000000 = 35184372088832
		/// </summary>
		public const long B64_45 = 0x0000200000000000;
		/// <summary>
		/// 0x00003FFFFFFFFFFF = 70368744177663
		/// </summary>
		public const long F64_45 = 0x00003FFFFFFFFFFF;

		/// <summary>
		/// 0x0000400000000000 = 70368744177664
		/// </summary>
		public const long B64_46 = 0x0000400000000000;
		/// <summary>
		/// 0x00007FFFFFFFFFFF = 140737488355327
		/// </summary>
		public const long F64_46 = 0x00007FFFFFFFFFFF;

		/// <summary>
		/// 0x0000800000000000 = 140737488355328
		/// </summary>
		public const long B64_47 = 0x0000800000000000;
		/// <summary>
		/// 0x0000FFFFFFFFFFFF = 281474976710655
		/// </summary>
		public const long F64_47 = 0x0000FFFFFFFFFFFF;

		/// <summary>
		/// 0x0001000000000000 = 281474976710656
		/// </summary>
		public const long B64_48 = 0x0001000000000000;
		/// <summary>
		/// 0x0001FFFFFFFFFFFF = 562949953421311
		/// </summary>
		public const long F64_48 = 0x0001FFFFFFFFFFFF;

		/// <summary>
		/// 0x0002000000000000 = 562949953421312
		/// </summary>
		public const long B64_49 = 0x0002000000000000;
		/// <summary>
		/// 0x0003FFFFFFFFFFFF = 1125899906842623
		/// </summary>
		public const long F64_49 = 0x0003FFFFFFFFFFFF;

		/// <summary>
		/// 0x0004000000000000 = 1125899906842624
		/// </summary>
		public const long B64_50 = 0x0004000000000000;
		/// <summary>
		/// 0x0007FFFFFFFFFFFF = 2251799813685247
		/// </summary>
		public const long F64_50 = 0x0007FFFFFFFFFFFF;

		/// <summary>
		/// 0x0008000000000000 = 2251799813685248
		/// </summary>
		public const long B64_51 = 0x0008000000000000;
		/// <summary>
		/// 0x000FFFFFFFFFFFFF = 4503599627370495
		/// </summary>
		public const long F64_51 = 0x000FFFFFFFFFFFFF;

		/// <summary>
		/// 0x0010000000000000 = 4503599627370496
		/// </summary>
		public const long B64_52 = 0x0010000000000000;
		/// <summary>
		/// 0x001FFFFFFFFFFFFF = 9007199254740991
		/// </summary>
		public const long F64_52 = 0x001FFFFFFFFFFFFF;

		/// <summary>
		/// 0x0020000000000000 = 9007199254740992
		/// </summary>
		public const long B64_53 = 0x0020000000000000;
		/// <summary>
		/// 0x003FFFFFFFFFFFFF = 18014398509481983
		/// </summary>
		public const long F64_53 = 0x003FFFFFFFFFFFFF;

		/// <summary>
		/// 0x0040000000000000 = 18014398509481984
		/// </summary>
		public const long B64_54 = 0x0040000000000000;
		/// <summary>
		/// 0x007FFFFFFFFFFFFF = 36028797018963967
		/// </summary>
		public const long F64_54 = 0x007FFFFFFFFFFFFF;

		/// <summary>
		/// 0x0080000000000000 = 36028797018963968
		/// </summary>
		public const long B64_55 = 0x0080000000000000;
		/// <summary>
		/// 0x00FFFFFFFFFFFFFF = 72057594037927935
		/// </summary>
		public const long F64_55 = 0x00FFFFFFFFFFFFFF;

		/// <summary>
		/// 0x0100000000000000 = 72057594037927936
		/// </summary>
		public const long B64_56 = 0x0100000000000000;
		/// <summary>
		/// 0x01FFFFFFFFFFFFFF = 144115188075855871
		/// </summary>
		public const long F64_56 = 0x01FFFFFFFFFFFFFF;

		/// <summary>
		/// 0x0200000000000000 = 144115188075855872
		/// </summary>
		public const long B64_57 = 0x0200000000000000;
		/// <summary>
		/// 0x03FFFFFFFFFFFFFF = 288230376151711743
		/// </summary>
		public const long F64_57 = 0x03FFFFFFFFFFFFFF;

		/// <summary>
		/// 0x0400000000000000 = 288230376151711744
		/// </summary>
		public const long B64_58 = 0x0400000000000000;
		/// <summary>
		/// 0x07FFFFFFFFFFFFFF = 576460752303423487
		/// </summary>
		public const long F64_58 = 0x07FFFFFFFFFFFFFF;

		/// <summary>
		/// 0x0800000000000000 = 576460752303423488
		/// </summary>
		public const long B64_59 = 0x0800000000000000;
		/// <summary>
		/// 0x0FFFFFFFFFFFFFFF = 1152921504606846975
		/// </summary>
		public const long F64_59 = 0x0FFFFFFFFFFFFFFF;

		/// <summary>
		/// 0x1000000000000000 = 1152921504606846976
		/// </summary>
		public const long B64_60 = 0x1000000000000000;
		/// <summary>
		/// 0x1FFFFFFFFFFFFFFF = 2305843009213693951
		/// </summary>
		public const long F64_60 = 0x1FFFFFFFFFFFFFFF;

		/// <summary>
		/// 0x2000000000000000 = 2305843009213693952
		/// </summary>
		public const long B64_61 = 0x2000000000000000;
		/// <summary>
		/// 0x3FFFFFFFFFFFFFFF = 4611686018427387903
		/// </summary>
		public const long F64_61 = 0x3FFFFFFFFFFFFFFF;

		/// <summary>
		/// 0x4000000000000000 = 4611686018427387904
		/// </summary>
		public const long B64_62 = 0x4000000000000000;
		/// <summary>
		/// 0x4FFFFFFFFFFFFFFF = 9223372036854775807
		/// </summary>
		public const long F64_62 = long.MaxValue;

		/// <summary>
		/// 0x8000000000000000 = -9223372036854775808
		/// </summary>
		public const long B64_63 = long.MinValue;
		/// <summary>
		/// 0xFFFFFFFFFFFFFFFF = -1
		/// </summary>
		public const long F64_63 = B64_TRUE;

		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static long B64_2Pow(long v)
		{
			return B64_2Pow(v, false);
		}
		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <param name="full">全位</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static long B64_2Pow(long v, bool full = false)
		{
			switch (v % 64)
			{
				case 0:
					if (full)
						return F64_00;

					return B64_00;
				case 1:
					if (full)
						return F64_01;

					return B64_01;
				case 2:
					if (full)
						return F64_02;

					return B64_02;
				case 3:
					if (full)
						return F64_03;

					return B64_03;
				case 4:
					if (full)
						return F64_04;

					return B64_04;
				case 5:
					if (full)
						return F64_05;

					return B64_05;
				case 6:
					if (full)
						return F64_06;

					return B64_06;
				case 7:
					if (full)
						return F64_07;

					return B64_07;
				case 8:
					if (full)
						return F64_08;

					return B64_08;
				case 9:
					if (full)
						return F64_09;

					return B64_09;
				case 10:
					if (full)
						return F64_10;

					return B64_10;
				case 11:
					if (full)
						return F64_11;

					return B64_11;
				case 12:
					if (full)
						return F64_12;

					return B64_12;
				case 13:
					if (full)
						return F64_13;

					return B64_13;
				case 14:
					if (full)
						return F64_14;

					return B64_14;
				case 15:
					if (full)
						return F64_15;

					return B64_15;
				case 16:
					if (full)
						return F64_16;

					return B64_16;
				case 17:
					if (full)
						return F64_17;

					return B64_17;
				case 18:
					if (full)
						return F64_18;

					return B64_18;
				case 19:
					if (full)
						return F64_19;

					return B64_19;
				case 20:
					if (full)
						return F64_20;

					return B64_20;
				case 21:
					if (full)
						return F64_21;

					return B64_21;
				case 22:
					if (full)
						return F64_22;

					return B64_22;
				case 23:
					if (full)
						return F64_23;

					return B64_23;
				case 24:
					if (full)
						return F64_24;

					return B64_24;
				case 25:
					if (full)
						return F64_25;

					return B64_25;
				case 26:
					if (full)
						return F64_26;

					return B64_26;
				case 27:
					if (full)
						return F64_27;

					return B64_27;
				case 28:
					if (full)
						return F64_28;

					return B64_28;
				case 29:
					if (full)
						return F64_29;

					return B64_29;
				case 30:
					if (full)
						return F64_30;

					return B64_30;
				case 31:
					if (full)
						return F64_31;

					return B64_31;
				case 32:
					if (full)
						return F64_32;

					return B64_32;
				case 33:
					if (full)
						return F64_33;

					return B64_33;
				case 34:
					if (full)
						return F64_34;

					return B64_34;
				case 35:
					if (full)
						return F64_35;

					return B64_35;
				case 36:
					if (full)
						return F64_36;

					return B64_36;
				case 37:
					if (full)
						return F64_37;

					return B64_37;
				case 38:
					if (full)
						return F64_38;

					return B64_38;
				case 39:
					if (full)
						return F64_39;

					return B64_39;
				case 40:
					if (full)
						return F64_40;

					return B64_40;
				case 41:
					if (full)
						return F64_41;

					return B64_41;
				case 42:
					if (full)
						return F64_42;

					return B64_42;
				case 43:
					if (full)
						return F64_43;

					return B64_43;
				case 44:
					if (full)
						return F64_44;

					return B64_44;
				case 45:
					if (full)
						return F64_45;

					return B64_45;
				case 46:
					if (full)
						return F64_46;

					return B64_46;
				case 47:
					if (full)
						return F64_47;

					return B64_47;
				case 48:
					if (full)
						return F64_48;

					return B64_48;
				case 49:
					if (full)
						return F64_49;

					return B64_49;
				case 50:
					if (full)
						return F64_50;

					return B64_50;
				case 51:
					if (full)
						return F64_51;

					return B64_51;
				case 52:
					if (full)
						return F64_52;

					return B64_52;
				case 53:
					if (full)
						return F64_53;

					return B64_53;
				case 54:
					if (full)
						return F64_54;

					return B64_54;
				case 55:
					if (full)
						return F64_55;

					return B64_55;
				case 56:
					if (full)
						return F64_56;

					return B64_56;
				case 57:
					if (full)
						return F64_57;

					return B64_57;
				case 58:
					if (full)
						return F64_58;

					return B64_58;
				case 59:
					if (full)
						return F64_59;

					return B64_59;
				case 60:
					if (full)
						return F64_60;

					return B64_60;
				case 61:
					if (full)
						return F64_61;

					return B64_61;
				case 62:
					if (full)
						return F64_62;

					return B64_62;
				case 63:
					if (full)
						return F64_63;

					return B64_63;
			}

			return B64_TRUE;
		}

		#endregion

		#region B32

		/// <summary>
		/// 0x00000001 = 1
		/// </summary>
		public const int B32_00 = 0x00000001;
		/// <summary>
		/// 0x00000001 = 1
		/// </summary>
		public const int F32_00 = 0x00000001;

		/// <summary>
		/// 0x00000002 = 2
		/// </summary>
		public const int B32_01 = 0x00000002;
		/// <summary>
		/// 0x00000003 = 3
		/// </summary>
		public const int F32_01 = 0x00000003;

		/// <summary>
		/// 0x00000004 = 4
		/// </summary>
		public const int B32_02 = 0x00000004;
		/// <summary>
		/// 0x00000007 = 7
		/// </summary>
		public const int F32_02 = 0x00000007;

		/// <summary>
		/// 0x00000008 = 8
		/// </summary>
		public const int B32_03 = 0x00000008;
		/// <summary>
		/// 0x0000000F = 15
		/// </summary>
		public const int F32_03 = 0x0000000F;

		/// <summary>
		/// 0x00000010 = 16
		/// </summary>
		public const int B32_04 = 0x00000010;
		/// <summary>
		/// 0x00000010 = 31
		/// </summary>
		public const int F32_04 = 0x0000001F;

		/// <summary>
		/// 0x00000020 = 32
		/// </summary>
		public const int B32_05 = 0x00000020;
		/// <summary>
		/// 0x0000003F = 63
		/// </summary>
		public const int F32_05 = 0x0000003F;

		/// <summary>
		/// 0x00000040 = 64
		/// </summary>
		public const int B32_06 = 0x00000040;
		/// <summary>
		/// 0x0000007F = 127
		/// </summary>
		public const int F32_06 = 0x0000007F;

		/// <summary>
		/// 0x00000080 = 128
		/// </summary>
		public const int B32_07 = 0x00000080;
		/// <summary>
		/// 0x000000FF = 255
		/// </summary>
		public const int F32_07 = 0x000000FF;

		/// <summary>
		/// 0x00000100 = 256
		/// </summary>
		public const int B32_08 = 0x00000100;
		/// <summary>
		/// 0x000001FF = 511
		/// </summary>
		public const int F32_08 = 0x000001FF;

		/// <summary>
		/// 0x00000200 = 512
		/// </summary>
		public const int B32_09 = 0x00000200;
		/// <summary>
		/// 0x000003FF = 1023
		/// </summary>
		public const int F32_09 = 0x000003FF;

		/// <summary>
		/// 0x00000400 = 1024
		/// </summary>
		public const int B32_10 = 0x00000400;
		/// <summary>
		/// 0x000007FF = 2047
		/// </summary>
		public const int F32_10 = 0x000007FF;

		/// <summary>
		/// 0x00000800 = 2048
		/// </summary>
		public const int B32_11 = 0x00000800;
		/// <summary>
		/// 0x00000FFF = 4095
		/// </summary>
		public const int F32_11 = 0x00000FFF;

		/// <summary>
		/// 0x00001000 = 4096
		/// </summary>
		public const int B32_12 = 0x00001000;
		/// <summary>
		/// 0x00001FFF = 8191
		/// </summary>
		public const int F32_12 = 0x00001FFF;

		/// <summary>
		/// 0x00002000 = 8192
		/// </summary>
		public const int B32_13 = 0x00002000;
		/// <summary>
		/// 0x00003FFF = 16383
		/// </summary>
		public const int F32_13 = 0x00003FFF;

		/// <summary>
		/// 0x00004000 = 16384
		/// </summary>
		public const int B32_14 = 0x00004000;
		/// <summary>
		/// 0x00007FFF = 32767
		/// </summary>
		public const int F32_14 = 0x00007FFF;

		/// <summary>
		/// 0x00008000 = 32768
		/// </summary>
		public const int B32_15 = 0x00008000;
		/// <summary>
		/// 0x0000FFFF = 65535
		/// </summary>
		public const int F32_15 = 0x0000FFFF;

		/// <summary>
		/// 0x00010000 = 65536
		/// </summary>
		public const int B32_16 = 0x00010000;
		/// <summary>
		/// 0x0001FFFF = 131071
		/// </summary>
		public const int F32_16 = 0x0001FFFF;

		/// <summary>
		/// 0x00020000 = 131072
		/// </summary>
		public const int B32_17 = 0x00020000;
		/// <summary>
		/// 0x0003FFFF = 262143
		/// </summary>
		public const int F32_17 = 0x0003FFFF;

		/// <summary>
		/// 0x00040000 = 262144
		/// </summary>
		public const int B32_18 = 0x00040000;
		/// <summary>
		/// 0x0007FFFF = 524287
		/// </summary>
		public const int F32_18 = 0x0007FFFF;

		/// <summary>
		/// 0x00080000 = 524288
		/// </summary>
		public const int B32_19 = 0x00080000;
		/// <summary>
		/// 0x000FFFFF = 1048575
		/// </summary>
		public const int F32_19 = 0x000FFFFF;

		/// <summary>
		/// 0x00100000 = 1048576
		/// </summary>
		public const int B32_20 = 0x00100000;
		/// <summary>
		/// 0x001FFFFF = 2097151
		/// </summary>
		public const int F32_20 = 0x001FFFFF;

		/// <summary>
		/// 0x00200000 = 2097152
		/// </summary>
		public const int B32_21 = 0x00200000;
		/// <summary>
		/// 0x003FFFFF = 4194303
		/// </summary>
		public const int F32_21 = 0x003FFFFF;

		/// <summary>
		/// 0x00400000 = 4194304
		/// </summary>
		public const int B32_22 = 0x00400000;
		/// <summary>
		/// 0x007FFFFF = 8388607
		/// </summary>
		public const int F32_22 = 0x007FFFFF;

		/// <summary>
		/// 0x00800000 = 8388608
		/// </summary>
		public const int B32_23 = 0x00800000;
		/// <summary>
		/// 0x00FFFFFF = 16777215
		/// </summary>
		public const int F32_23 = 0x00FFFFFF;

		/// <summary>
		/// 0x01000000 = 16777216
		/// </summary>
		public const int B32_24 = 0x01000000;
		/// <summary>
		/// 0x01FFFFFF = 33554431
		/// </summary>
		public const int F32_24 = 0x01FFFFFF;

		/// <summary>
		/// 0x02000000 = 33554432
		/// </summary>
		public const int B32_25 = 0x02000000;
		/// <summary>
		/// 0x03FFFFFF = 67108863
		/// </summary>
		public const int F32_25 = 0x03FFFFFF;

		/// <summary>
		/// 0x04000000 = 67108864
		/// </summary>
		public const int B32_26 = 0x04000000;
		/// <summary>
		/// 0x07FFFFFF = 134217727
		/// </summary>
		public const int F32_26 = 0x07FFFFFF;

		/// <summary>
		/// 0x08000000 = 134217728
		/// </summary>
		public const int B32_27 = 0x08000000;
		/// <summary>
		/// 0x0FFFFFFF = 268435455
		/// </summary>
		public const int F32_27 = 0x0FFFFFFF;

		/// <summary>
		/// 0x10000000 = 268435456
		/// </summary>
		public const int B32_28 = 0x10000000;
		/// <summary>
		/// 0x1FFFFFFF = 536870911
		/// </summary>
		public const int F32_28 = 0x1FFFFFFF;

		/// <summary>
		/// 0x20000000 = 536870912
		/// </summary>
		public const int B32_29 = 0x20000000;
		/// <summary>
		/// 0x3FFFFFFF = 1073741823
		/// </summary>
		public const int F32_29 = 0x3FFFFFFF;

		/// <summary>
		/// 0x40000000 = 1073741824
		/// </summary>
		public const int B32_30 = 0x40000000;
		/// <summary>
		/// 0x7FFFFFFF = 2147483647
		/// </summary>
		public const int F32_30 = int.MaxValue;

		/// <summary>
		/// 0x80000000 = -2147483648
		/// </summary>
		public const int B32_31 = int.MinValue;
		/// <summary>
		/// 0xFFFFFFFF = -1
		/// </summary>
		public const int F32_31 = B32_TRUE;

		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static int B32_2Pow(int v)
		{
			return B32_2Pow(v, false);
		}
		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <param name="full">全位</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static int B32_2Pow(int v, bool full = false)
		{
			switch (v % 32)
			{
				case 0:
					if (full)
						return F32_00;

					return B32_00;
				case 1:
					if (full)
						return F32_01;

					return B32_01;
				case 2:
					if (full)
						return F32_02;

					return B32_02;
				case 3:
					if (full)
						return F32_03;

					return B32_03;
				case 4:
					if (full)
						return F32_04;

					return B32_04;
				case 5:
					if (full)
						return F32_05;

					return B32_05;
				case 6:
					if (full)
						return F32_06;

					return B32_06;
				case 7:
					if (full)
						return F32_07;

					return B32_07;
				case 8:
					if (full)
						return F32_08;

					return B32_08;
				case 9:
					if (full)
						return F32_09;

					return B32_09;
				case 10:
					if (full)
						return F32_10;

					return B32_10;
				case 11:
					if (full)
						return F32_11;

					return B32_11;
				case 12:
					if (full)
						return F32_12;

					return B32_12;
				case 13:
					if (full)
						return F32_13;

					return B32_13;
				case 14:
					if (full)
						return F32_14;

					return B32_14;
				case 15:
					if (full)
						return F32_15;

					return B32_15;
				case 16:
					if (full)
						return F32_16;

					return B32_16;
				case 17:
					if (full)
						return F32_17;

					return B32_17;
				case 18:
					if (full)
						return F32_18;

					return B32_18;
				case 19:
					if (full)
						return F32_19;

					return B32_19;
				case 20:
					if (full)
						return F32_20;

					return B32_20;
				case 21:
					if (full)
						return F32_21;

					return B32_21;
				case 22:
					if (full)
						return F32_22;

					return B32_22;
				case 23:
					if (full)
						return F32_23;

					return B32_23;
				case 24:
					if (full)
						return F32_24;

					return B32_24;
				case 25:
					if (full)
						return F32_25;

					return B32_25;
				case 26:
					if (full)
						return F32_26;

					return B32_26;
				case 27:
					if (full)
						return F32_27;

					return B32_27;
				case 28:
					if (full)
						return F32_28;

					return B32_28;
				case 29:
					if (full)
						return F32_29;

					return B32_29;
				case 30:
					if (full)
						return F32_30;

					return B32_30;
				case 31:
					if (full)
						return F32_31;

					return B32_31;
			}

			return B32_TRUE;
		}

		#endregion

		#region B16

		/// <summary>
		/// 0x0001 = 1
		/// </summary>
		public const short B16_00 = 0x0001;
		/// <summary>
		/// 0x0001 = 1
		/// </summary>
		public const short F16_00 = 0x0001;

		/// <summary>
		/// 0x0002 = 2
		/// </summary>
		public const short B16_01 = 0x0002;
		/// <summary>
		/// 0x0003 = 3
		/// </summary>
		public const short F16_01 = 0x0003;

		/// <summary>
		/// 0x0004 = 4
		/// </summary>
		public const short B16_02 = 0x0004;
		/// <summary>
		/// 0x0007 = 7
		/// </summary>
		public const short F16_02 = 0x0007;

		/// <summary>
		/// 0x0008 = 8
		/// </summary>
		public const short B16_03 = 0x0008;
		/// <summary>
		/// 0x000F = 15
		/// </summary>
		public const short F16_03 = 0x000F;

		/// <summary>
		/// 0x0010 = 16
		/// </summary>
		public const short B16_04 = 0x0010;
		/// <summary>
		/// 0x001F = 31
		/// </summary>
		public const short F16_04 = 0x001F;

		/// <summary>
		/// 0x0020 = 32
		/// </summary>
		public const short B16_05 = 0x0020;
		/// <summary>
		/// 0x003F = 63
		/// </summary>
		public const short F16_05 = 0x003F;

		/// <summary>
		/// 0x0040 = 64
		/// </summary>
		public const short B16_06 = 0x0040;
		/// <summary>
		/// 0x007F = 127
		/// </summary>
		public const short F16_06 = 0x007F;

		/// <summary>
		/// 0x0080 = 128
		/// </summary>
		public const short B16_07 = 0x0080;
		/// <summary>
		/// 0x00FF = 255
		/// </summary>
		public const short F16_07 = 0x00FF;

		/// <summary>
		/// 0x0100 = 256
		/// </summary>
		public const short B16_08 = 0x0100;
		/// <summary>
		/// 0x01FF = 511
		/// </summary>
		public const short F16_08 = 0x01FF;

		/// <summary>
		/// 0x0200 = 512
		/// </summary>
		public const short B16_09 = 0x0200;
		/// <summary>
		/// 0x03FF = 1023
		/// </summary>
		public const short F16_09 = 0x03FF;

		/// <summary>
		/// 0x0400 = 1024
		/// </summary>
		public const short B16_10 = 0x0400;
		/// <summary>
		/// 0x07FF = 2047
		/// </summary>
		public const short F16_10 = 0x07FF;

		/// <summary>
		/// 0x0800 = 2048
		/// </summary>
		public const short B16_11 = 0x0800;
		/// <summary>
		/// 0x0FFF = 4095
		/// </summary>
		public const short F16_11 = 0x0FFF;

		/// <summary>
		/// 0x1000 = 4096
		/// </summary>
		public const short B16_12 = 0x1000;
		/// <summary>
		/// 0x1FFF = 8191
		/// </summary>
		public const short F16_12 = 0x1FFF;

		/// <summary>
		/// 0x2000 = 8192
		/// </summary>
		public const short B16_13 = 0x2000;
		/// <summary>
		/// 0x3FFF = 16383
		/// </summary>
		public const short F16_13 = 0x3FFF;

		/// <summary>
		/// 0x4000 = 16384
		/// </summary>
		public const short B16_14 = 0x4000;
		/// <summary>
		/// 0x7FFF = 32767
		/// </summary>
		public const short F16_14 = short.MaxValue;

		/// <summary>
		/// 0x8000 = -32768
		/// </summary>
		public const short B16_15 = short.MinValue;
		/// <summary>
		/// 0xFFFF = -1
		/// </summary>
		public const short F16_15 = B16_TRUE;

		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static short B16_2Pow(int v)
		{
			return B16_2Pow(v, false);
		}
		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <param name="full">全位</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static short B16_2Pow(int v, bool full = false)
		{
			switch (v % 16)
			{
				case 0:
					if (full)
						return F16_00;

					return B16_00;
				case 1:
					if (full)
						return F16_01;

					return B16_01;
				case 2:
					if (full)
						return F16_02;

					return B16_02;
				case 3:
					if (full)
						return F16_03;

					return B16_03;
				case 4:
					if (full)
						return F16_04;

					return B16_04;
				case 5:
					if (full)
						return F16_05;

					return B16_05;
				case 6:
					if (full)
						return F16_06;

					return B16_06;
				case 7:
					if (full)
						return F16_07;

					return B16_07;
				case 8:
					if (full)
						return F16_08;

					return B16_08;
				case 9:
					if (full)
						return F16_09;

					return B16_09;
				case 10:
					if (full)
						return F16_10;

					return B16_10;
				case 11:
					if (full)
						return F16_11;

					return B16_11;
				case 12:
					if (full)
						return F16_12;

					return B16_12;
				case 13:
					if (full)
						return F16_13;

					return B16_13;
				case 14:
					if (full)
						return F16_14;

					return B16_14;
				case 15:
					if (full)
						return F16_15;

					return B16_15;
			}

			return B16_TRUE;
		}

		#endregion

		#region BS8

		/// <summary>
		/// 0x01 = 1
		/// </summary>
		public const sbyte BS8_00 = 0x01;
		/// <summary>
		/// 0x01 = 1
		/// </summary>
		public const sbyte FS8_00 = 0x01;

		/// <summary>
		/// 0x02 = 2
		/// </summary>
		public const sbyte BS8_01 = 0x02;
		/// <summary>
		/// 0x03 = 3
		/// </summary>
		public const sbyte FS8_01 = 0x03;

		/// <summary>
		/// 0x04 = 4
		/// </summary>
		public const sbyte BS8_02 = 0x04;
		/// <summary>
		/// 0x07 = 7
		/// </summary>
		public const sbyte FS8_02 = 0x07;

		/// <summary>
		/// 0x08 = 8
		/// </summary>
		public const sbyte BS8_03 = 0x08;
		/// <summary>
		/// 0x0F = 15
		/// </summary>
		public const sbyte FS8_03 = 0x0F;

		/// <summary>
		/// 0x10 = 16
		/// </summary>
		public const sbyte BS8_04 = 0x10;
		/// <summary>
		/// 0x1F = 31
		/// </summary>
		public const sbyte FS8_04 = 0x1F;

		/// <summary>
		/// 0x20 = 32
		/// </summary>
		public const sbyte BS8_05 = 0x20;
		/// <summary>
		/// 0x3F = 63
		/// </summary>
		public const sbyte FS8_05 = 0x3F;

		/// <summary>
		/// 0x40 = 64
		/// </summary>
		public const sbyte BS8_06 = 0x40;
		/// <summary>
		/// 0x7F = 127
		/// </summary>
		public const sbyte FS8_06 = sbyte.MaxValue;

		/// <summary>
		/// 0x80 = -128
		/// </summary>
		public const sbyte BS8_07 = sbyte.MinValue;
		/// <summary>
		/// 0xFF = -1
		/// </summary>
		public const sbyte FS8_07 = BS8_TRUE;

		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static sbyte BS8_2Pow(int v)
		{
			return BS8_2Pow(v, false);
		}

		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <param name="full">全位</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static sbyte BS8_2Pow(int v, bool full = false)
		{
			switch (v % 8)
			{
				case 0:
					if (full)
						return FS8_00;

					return BS8_00;
				case 1:
					if (full)
						return FS8_01;

					return BS8_01;
				case 2:
					if (full)
						return FS8_02;

					return BS8_02;
				case 3:
					if (full)
						return FS8_03;

					return BS8_03;
				case 4:
					if (full)
						return FS8_04;

					return BS8_04;
				case 5:
					if (full)
						return FS8_05;

					return BS8_05;
				case 6:
					if (full)
						return FS8_06;

					return BS8_06;
				case 7:
					if (full)
						return FS8_07;

					return BS8_07;
			}

			return BS8_TRUE;
		}

		#endregion

		#region B08

		/// <summary>
		/// 0x01 = 1
		/// </summary>
		public const byte B08_00 = 0x01;
		/// <summary>
		/// 0x01 = 1
		/// </summary>
		public const byte F08_00 = 0x01;

		/// <summary>
		/// 0x02 = 2
		/// </summary>
		public const byte B08_01 = 0x02;
		/// <summary>
		/// 0x03 = 3
		/// </summary>
		public const byte F08_01 = 0x03;

		/// <summary>
		/// 0x04 = 4
		/// </summary>
		public const byte B08_02 = 0x04;
		/// <summary>
		/// 0x07 = 7
		/// </summary>
		public const byte F08_02 = 0x07;

		/// <summary>
		/// 0x08 = 8
		/// </summary>
		public const byte B08_03 = 0x08;
		/// <summary>
		/// 0x0F = 15
		/// </summary>
		public const byte F08_03 = 0x0F;

		/// <summary>
		/// 0x10 = 16
		/// </summary>
		public const byte B08_04 = 0x10;
		/// <summary>
		/// 0x1F = 31
		/// </summary>
		public const byte F08_04 = 0x1F;

		/// <summary>
		/// 0x20 = 32
		/// </summary>
		public const byte B08_05 = 0x20;
		/// <summary>
		/// 0x3F = 63
		/// </summary>
		public const byte F08_05 = 0x3F;

		/// <summary>
		/// 0x40 = 64
		/// </summary>
		public const byte B08_06 = 0x40;
		/// <summary>
		/// 0x7F = 127
		/// </summary>
		public const byte F08_06 = 0x7F;

		/// <summary>
		/// 0x80 = 128
		/// </summary>
		public const byte B08_07 = 0x80;
		/// <summary>
		/// 0xFF = 255
		/// </summary>
		public const byte F08_07 = 0xFF;

		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static byte B08_2Pow(int v)
		{
			return B08_2Pow(v, false);
		}
		/// <summary>
		/// 取以 2 为底的整数次幂
		/// </summary>
		/// <param name="v">幂指数</param>
		/// <param name="full">全位</param>
		/// <returns>返回 2 的 v 次方</returns>
		public static byte B08_2Pow(int v, bool full = false)
		{
			switch (v % 8)
			{
				case 0:
					if (full)
						return F08_00;

					return B08_00;
				case 1:
					if (full)
						return F08_01;

					return B08_01;
				case 2:
					if (full)
						return F08_02;

					return B08_02;
				case 3:
					if (full)
						return F08_03;

					return B08_03;
				case 4:
					if (full)
						return F08_04;

					return B08_04;
				case 5:
					if (full)
						return F08_05;

					return B08_05;
				case 6:
					if (full)
						return F08_06;

					return B08_06;
				case 7:
					if (full)
						return F08_07;

					return B08_07;
			}

			return B08_ZERO;
		}

		#endregion

		/// <summary>
		/// 0x08 = 8
		/// </summary>
		public const int B = B08_03;
		/// <summary>
		/// 0x0400 = 1024
		/// </summary>
		public const int K = B16_10;
		/// <summary>
		/// 0x00100000 = 1048576
		/// </summary>
		public const int M = B32_20;
		/// <summary>
		/// 0x40000000 = 1073741824
		/// </summary>
		public const int G = B32_30;
		/// <summary>
		/// 0x0000010000000000 = 1099511627776
		/// </summary>
		public const long T = B64_40;
		/// <summary>
		/// 0x0004000000000000 = 1125899906842624
		/// </summary>
		public const long P = B64_50;
		/// <summary>
		/// 0x1000000000000000 = 1152921504606846976
		/// </summary>
		public const long E = B64_60;

		/// <summary>一个字节的内存大小</summary>
		public const int SIZE_B08 = sizeof(byte);
		/// <summary>一个短整形的内存大小</summary>
		public const int SIZE_B16 = sizeof(short);
		/// <summary>一个整形的内存大小</summary>
		public const int SIZE_B32 = sizeof(int);
		/// <summary>一个长整形的内存大小</summary>
		public const int SIZE_B64 = sizeof(long);
		/// <summary>一个全球标识符的内存大小</summary>
		public static readonly int SIZE_GUID = Marshal.SizeOf(Guid.Empty);//sizeof(Guid);//
		/// <summary>一个时间的内存大小</summary>
		public const int SIZE_TIME = sizeof(long);
		/// <summary>一个IP的内存大小</summary>
		public const int SIZE_IP = sizeof(int);
		/// <summary>一个IPv6的内存大小</summary>
		public static readonly int SIZE_IP6 = Marshal.SizeOf(Guid.Empty);

		#region Set Get Value

		/// <summary>
		/// 添加位
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">位</param>
		/// <returns>添加位后的值</returns>
		public static long Append(long value, params long[] keys)
		{
			foreach (var item in keys)
				value |= item;
			return value;
		}

		/// <summary>
		/// 单选位
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">所选值</param>
		/// <param name="keys">可选位列表</param>
		/// <returns>单选位后的值</returns>
		// <exception cref="System.ArgumentOutOfRangeException">所选值非在可选列表中非单选，不在可选列表中</exception>
		public static long Single(long value, long key, params long[] keys)
		{
			foreach (var item in keys)
			{
				value |= item;
				if (key != item)
					value ^= item;
			}
			return value;
		}

		/// <summary>
		/// 删除位
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">位</param>
		/// <returns>删除位后的值</returns>
		public static long Remove(long value, params long[] keys)
		{
			foreach (var item in keys)
			{
				value |= item;
				value ^= item;
			}
			return value;
		}

		/// <summary>
		/// 反转位，异或，非倒序位，对某位进行反转，如果为真则设为假，如果为假则设为真
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">位</param>
		/// <returns>反转后的值</returns>
		public static long Reverse(long value, params long[] keys)//reverse
		{
			foreach (var item in keys)
				value ^= item;
			return value;
		}

		/// <summary>
		/// 设置值
		/// </summary>
		/// <param name="data">原数据值</param>
		/// <param name="key">位</param>
		/// <param name="value">位值</param>
		/// <returns>设定后的值</returns>
		public static long SetValue(long data, long key, bool value)
		{
			data |= key;
			if (!value)
				data ^= key;
			return data;
		}

		/// <summary>
		/// 是否包含指定位的值
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">位</param>
		/// <returns>是否包含，与值</returns>
		public static bool GetValue(long value, long key)
		{
			return (value & key) == key;
		}

		/// <summary>
		/// 设置位值
		/// </summary>
		/// <param name="data">数据</param>
		/// <param name="index">位索引</param>
		/// <param name="value">位值，零为假</param>
		/// <param name="host">是否低位优先，默认高位优先，即零位为(128)最高位</param>
		/// <returns>数据</returns>
		public static byte[] SetValue(byte[] data, int index, bool value, bool host = false)
		{
			var i = index / 8;
			var v = B08_2Pow(host ? (index % 8) : 8 - (index % 8) - 1);
			if (value)
				data[index / 8] = (byte)(data[i] | v);
			else
				data[index / 8] = (byte)((data[i] | v) ^ v);
			return data;
		}

		/// <summary>
		/// 获取位值
		/// </summary>
		/// <param name="data">数据</param>
		/// <param name="index">位索引</param>
		/// <param name="host">是否低位优先，默认高位优先，即零位为(128)最高位</param>
		/// <returns>位值，零为假</returns>
		public static bool GetValue(byte[] data, int index, bool host = false)
		{
			var i = index / 8;
			var v = B08_2Pow(host ? (index % 8) : 8 - (index % 8) - 1);
			if ((data[i] & v) == v)
				return true;

			return false;
		}

		#endregion

		/// <summary>
		/// 测试是否包含指定位的值
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">位</param>
		/// <returns>是否包含</returns>
		public static bool Test(long value, long key)
		{
			return (value & key) == key;
		}

		/// <summary>
		/// 测试是否包含指定位的值
		/// </summary>
		/// <param name="value">值</param>
		/// <param name="key">位</param>
		/// <returns>是否包含</returns>
		public static bool Test(object value, long key)
		{
			if (value is decimal)
				return Test(decimal.ToInt64((decimal)value), key);

			if (value is long)
				return Test((long)value, key);

			if (value is int)
				return Test((int)value, key);

			if (value is short)
				return Test((short)value, key);

			if (value is byte)
				return Test((byte)value, key);

			return false;
		}

		/// <summary>
		/// 将短值由主机字节顺序转换为网络字节顺序。
		/// </summary>
		/// <param name="host">以主机字节顺序表示的要转换的数字。</param>
		/// <returns>以网络字节顺序表示的短值。</returns>
		public static short HostToNetworkOrder(short host)
		{
			return (short)(((host & F16_07) << B32_03) | ((host >> B32_03) & F16_07));
		}

		/// <summary>
		/// 将短值由主机字节顺序转换为网络字节顺序。
		/// </summary>
		/// <param name="host">以主机字节顺序表示的要转换的数字。</param>
		/// <returns>以网络字节顺序表示的短值。</returns>
		public static int HostToNetworkOrder(int host)
		{
			return (((HostToNetworkOrder((short)host) & F32_15) << B32_04) | (HostToNetworkOrder((short)(host >> B32_04)) & F32_15));
		}

		/// <summary>
		/// 将短值由主机字节顺序转换为网络字节顺序。
		/// </summary>
		/// <param name="host">以主机字节顺序表示的要转换的数字。</param>
		/// <returns>以网络字节顺序表示的短值。</returns>
		public static long HostToNetworkOrder(long host)
		{
			return (long)(((HostToNetworkOrder((int)host) & F64_31) << B32_05) | (HostToNetworkOrder((int)(host >> B32_05)) & F64_31));
		}

		/// <summary>
		/// 将短值由网络字节顺序转换为主机字节顺序。
		/// </summary>
		/// <param name="network">以网络字节顺序表示的要转换的数字。</param>
		/// <returns>以主机字节顺序表示的短值。</returns>
		public static short NetworkToHostOrder(short network)
		{
			return HostToNetworkOrder(network);
		}

		/// <summary>
		/// 将整数值由网络字节顺序转换为主机字节顺序。
		/// </summary>
		/// <param name="network">以网络字节顺序表示的要转换的数字。</param>
		/// <returns>以主机字节顺序表示的整数值。</returns>
		public static int NetworkToHostOrder(int network)
		{
			return HostToNetworkOrder(network);
		}

		/// <summary>
		/// 将长值由网络字节顺序转换为主机字节顺序。
		/// </summary>
		/// <param name="network">以网络字节顺序表示的要转换的数字。</param>
		/// <returns>以主机字节顺序表示的长值。</returns>
		public static long NetworkToHostOrder(long network)
		{
			return HostToNetworkOrder(network);
		}
	}
}
